package com.example.teach.controller;

import com.example.teach.entity.Comment;
import com.example.teach.entity.Result;
import com.example.teach.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @PostMapping("/add")
    public Result addComment(@RequestBody Comment comment){
        return commentService.add(comment);
    }

    @DeleteMapping("/delete")
    public Result deleteComment(@RequestParam Integer contentId,
                                @RequestParam Integer articleId,
                                @RequestParam Integer userId){
        return commentService.delete(contentId,articleId,userId);
    }

    @GetMapping("/list")
    public Result list(@RequestParam Integer articleId){
        return commentService.select(articleId);
    }

}
